/*

* TCSS 422, Project 2 (Scheduler Simulation)

* Team 9 Name: blueraccoon422

* Team 9 Group Members: Jacob Hall, Jacob Mertens, Diana Gorun, Alex Stringham

* File Name: Queue.h

* Date: May 22, 2013

*/

#ifndef QUEUE_H_
#define QUEUE_H_
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <pthread.h>
#define TRUE 1
#define FALSE 0

//just define the type of queue, so we know which queue need to be added to.
#define READY_QUEUE 0
#define INTERRUPT_QUEUE 1
#define IO_KB_QUEUE 2
#define AUX_QUEUE 3

// Mutexes for queue so only one process can change the queue at a time.
pthread_mutex_t queue_mutex[4];

typedef struct Node {
        int priority;
        int PID;
        struct Node* next;
} Node;

typedef Node* NodePtr;

typedef struct Queue {
        int queue_type;
        struct Node* head;
        struct Node* tail;
} Queue;

typedef Queue* QueuePtr;

//global queues.
Queue* io_kb_queue;
Queue* ready_queue;
Queue* interrupt_queue;
Queue* auxiliary_queue;

//function prototype.
Queue* new_queue(int);
Queue* free_queue(Queue*);
Queue* add_queue(Queue*, int);
Queue* add_priority_queue(Queue*, int, int);
Node* remove_queue(Queue*);
Node* queue_peek(Queue*);
int queue_size(Queue*);
void print_queue(Queue*);
void queue_print_element(Node*);
int queue_isEmpty(Queue*);

#endif /* QUEUE_H_ */
